package movieGandalf.GUI;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.ProgressBar;


public class AdminPage extends Composite {

        private static final int DEFAULT_FONT_SIZE = 25;
        private static final String DEFAULT_FONT = "Segoe UI";
        private static final int MAXIMUM_PROGRESS = 500;
        private static final int BUTTON_SPACING = 40;
        private static final int BUTTON_HEIGHT = 60;


public AdminPage(Composite parent, int style) {
                super(parent, style);

                this.setLayout(new FormLayout());
                this.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));

                Button btnSyncAll = new Button(this, SWT.NONE);
                btnSyncAll.setFont(SWTResourceManager.getFont(DEFAULT_FONT,
                                DEFAULT_FONT_SIZE, SWT.BOLD));
                Button btnSyncImages = new Button(this, SWT.NONE);
                btnSyncImages.setFont(SWTResourceManager.getFont(DEFAULT_FONT,
                                DEFAULT_FONT_SIZE, SWT.BOLD));
                Button btnSyncArticles = new Button(this, SWT.NONE);
                btnSyncArticles.setFont(SWTResourceManager.getFont(DEFAULT_FONT,
                                DEFAULT_FONT_SIZE, SWT.BOLD));

                final ProgressBar progressBar = new ProgressBar(this, SWT.NONE);
                progressBar.setMaximum(MAXIMUM_PROGRESS);
                FormData fd_progressBar = new FormData();
                fd_progressBar.bottom = new FormAttachment(90);
                fd_progressBar.right = new FormAttachment(100, -10);
                fd_progressBar.left = new FormAttachment(0, 10);
                progressBar.setLayoutData(fd_progressBar);

                FormData fd_btnSyncAll = new FormData();
                fd_btnSyncAll.top = new FormAttachment(10);
                fd_btnSyncAll.bottom = new FormAttachment(10, BUTTON_HEIGHT);
                fd_btnSyncAll.left = new FormAttachment(25);
                fd_btnSyncAll.right = new FormAttachment(75);
                btnSyncAll.setLayoutData(fd_btnSyncAll);
                btnSyncAll.setText("Sync All");


                FormData fd_btnSyncImages = new FormData();
                fd_btnSyncImages.top = new FormAttachment(btnSyncAll, BUTTON_SPACING,
                                SWT.BOTTOM);
                fd_btnSyncImages.bottom = new FormAttachment(btnSyncAll, BUTTON_SPACING
                                + BUTTON_HEIGHT, SWT.BOTTOM);
                fd_btnSyncImages.left = new FormAttachment(btnSyncAll, 0, SWT.LEFT);
                fd_btnSyncImages.right = new FormAttachment(btnSyncAll, 0, SWT.RIGHT);
                btnSyncImages.setLayoutData(fd_btnSyncImages);
                btnSyncImages.setText("Sync Images");


                FormData fd_btnSyncArticles = new FormData();
                fd_btnSyncArticles.top = new FormAttachment(btnSyncImages,
                                BUTTON_SPACING, SWT.BOTTOM);
                fd_btnSyncArticles.bottom = new FormAttachment(btnSyncImages,
                                BUTTON_SPACING + BUTTON_HEIGHT, SWT.BOTTOM);
                fd_btnSyncArticles.left = new FormAttachment(btnSyncAll, 0, SWT.LEFT);
                fd_btnSyncArticles.right = new FormAttachment(btnSyncAll, 0, SWT.RIGHT);
                btnSyncArticles.setLayoutData(fd_btnSyncArticles);
                btnSyncArticles.setText("Sync Articles");

                this.setTabList(new Control[] { btnSyncArticles, btnSyncAll,
                                btnSyncImages, progressBar });
        }
}